<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>消缺任务的执行与回执</title>
    <link rel="stylesheet" href="/webjars/layui/2.5.5/css/layui.css"  media="all">
    <style>
        *{
            margin: 0px auto;
            padding: 0px;
        }
        .layui-table-cell{
            height: 30px;
        }
    </style>
</head>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item" style="margin-top: 50px">
        <div class="layui-inline">
            <label class="layui-form-label">任务编号</label>
            <div class="layui-input-inline">
                <input type="tel" name="solveTaskCode" id="solveTaskCode" lay-verify="required|phone" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">工作单据</label>
            <div class="layui-input-inline">
                <select  id="service" name="workDocType" lay-verify="required"  class="select">
                    <option value=" ">--请选择--</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item" style="margin-top: 10px">
        <div class="layui-inline">
            <label class="layui-form-label">下发人</label>
            <div class="layui-input-inline">
                <input type="tel" name="issuedByName" id="issuedByName" lay-verify="required|phone" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">下发时间：</label>
            <div class="layui-input-inline" style="width: 180px">
                <input type="text" class="layui-input"  name="issuedTime"  placeholder="" id="kaishi">
            </div>
            <div class="layui-form-mid">————</div>
            <div class="layui-input-inline" style="width: 180px">
                <input type="text" class="layui-input"  name="issuedTime" placeholder="" id="jeiShu">
            </div>
            <button type="button" class="layui-btn" style="margin-left: 80px" onclick="ChaXun()">查询</button>
        </div>
    </div>
</form>
<div class="layui-container" style="width:100%;margin-top:50px ">
    <table id="AttTb" lay-filter="AttTb" lay-data="AttTb"></table>
</div>

<!--修改-->
<div id="update" style="display: none" class="layui-form-item">
    <form class="layui-form" id="updateForm" lay-filter="updateForm">
    <div class="layui-form-item">
        <input type="hidden" name="id">
        <table cellpadding="0" cellspacing="0" border="1" style="margin-top: 10px">
            <tr style="height: 30px;">
                <td style="width: 180px;" align="center">任务编码</td>
                <td><input type="text" name="solveTaskCode" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                <td style="width: 180px;" align="center">任务名称</td>
                <td><input type="text" name="solveTaskName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
            </tr>
            <tr style="height: 30px;">
                <td style="width: 180px;" align="center">任务状态</td>
                <td><input type="text" name="taskStatusName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                <td style="width: 180px;" align="center">工作单据</td>
                <td><input type="text" name="workDocTypeName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
            </tr>
            <tr style="height: 30px;">
                <td style="width: 180px;" align="center">任务下发人</td>
                <td><input type="text" name="issuedByName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                <td style="width: 180px;" align="center">任务下发时间</td>
                <td><input type="text" name="issuedTime" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
            </tr>
            <tr style="height: 30px;">
                <td style="width: 180px;" align="center">任务负责人</td>
                <td><input type="text" name="taskManagerName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                <td style="width: 180px;" align="center">任务描述</td>
                <td><input type="text" name="taskDesc" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
            </tr>
            <tr style="height: 30px;">
                <td style="width: 180px;" align="center">消缺员</td>
                <td><input type="text" th:value="${session.loginUser.userName}" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                <td style="width: 180px;" align="center">任务完成时间</td>
                <td><input type="text" name="finishTime" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
            </tr>
            <tr style="height: 40px;">
                <td style="width: 180px;" align="center">负责人审查意见</td>
                <td><input type="text" name="managerSuggestion" disabled="disabled" style="border: none;height: 40px;padding-left: 20px"></td>
                <td style="width: 180px;" align="center">完成情况描述</td>
                <td><textarea placeholder="请输入内容" name="taskFinishDesc" id="taskFinishDesc1" class="layui-textarea" style="min-height:40px"></textarea></td>
            </tr>
            <tr style="height: 35px;">
                <td style="width: 180px;" align="center"> 下发人审查意见</td>
                <td><input type="text" name="issuedSuggestion" disabled="disabled" style="border: none;height: 35px;padding-left: 20px"></td>
                <td style="width: 180px;" align="center">审核是否通过</td>
                <td><input type="text" name="isCancel"  disabled="disabled" style="border: none;height: 35px;padding-left: 20px"></td>
            </tr>
        </table>
    </div>
<!--    <div style="margin-left: 100px;height: 200px;border: 1px slategrey solid">-->
<!--        <h4>缺陷信息列表</h4>-->
<!--        <table id="QueTb" lay-filter="QueTb" lay-data="QueTb"></table>-->
<!--    </div>-->
    <div class="layui-form-item layui-form-text">
        <h4 style="margin-left: 100px">工作间断延期记载</h4>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" name="taskNotes" id="taskNotes1" class="layui-textarea" style="min-height:60px"></textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <h4 style="margin-left: 100px">工作终结报告</h4>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" name="taskFinishReport" id="taskFinishReport1" class="layui-textarea" style="min-height:60px"></textarea>
        </div>
    </div>
    </form>
</div>

<div id="add" style="display: none" class="layui-form-item">
    <form class="layui-form" id="addForm" lay-filter="addForm">
        <div class="layui-form-item">
            <input type="hidden" name="id">
            <table cellpadding="0" cellspacing="0" border="1" style="margin-top: 10px">
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">任务编码</td>
                    <td><input type="text" name="solveTaskCode" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">任务名称</td>
                    <td><input type="text" name="solveTaskName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">任务状态</td>
                    <td><input type="text" name="taskStatusName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">工作单据</td>
                    <td><input type="text" name="workDocTypeName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">任务下发人</td>
                    <td><input type="text" name="issuedByName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">任务下发时间</td>
                    <td><input type="text" name="issuedTime" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">任务负责人</td>
                    <td><input type="text" name="taskManagerName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">任务描述</td>
                    <td><input type="text" name="taskDesc" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">消缺员</td>
                    <td><input type="text" th:value="${session.loginUser.userName}" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">任务完成时间</td>
                    <td><input type="text" name="finishTime" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 40px;">
                    <td style="width: 180px;" align="center">负责人审查意见</td>
                    <td><input type="text" name="managerSuggestion" disabled="disabled" style="border: none;height: 40px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">完成情况描述</td>
                    <td><textarea placeholder="请输入内容" name="taskFinishDesc" id="taskFinishDesc" class="layui-textarea" style="min-height:40px"></textarea></td>
                </tr>
                <tr style="height: 35px;">
                    <td style="width: 180px;" align="center"> 下发人审查意见</td>
                    <td><input type="text" name="issuedSuggestion" disabled="disabled" style="border: none;height: 35px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">审核是否通过</td>
                    <td><input type="text" name="isCancel"  disabled="disabled" style="border: none;height: 35px;padding-left: 20px"></td>
                </tr>
            </table>
        </div>
        <!--    <div style="margin-left: 100px;height: 200px;border: 1px slategrey solid">-->
        <!--        <h4>缺陷信息列表</h4>-->
        <!--        <table id="QueTb" lay-filter="QueTb" lay-data="QueTb"></table>-->
        <!--    </div>-->
        <div class="layui-form-item layui-form-text">
            <h4 style="margin-left: 100px">工作间断延期记载</h4>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" name="taskNotes" id="taskNotes" class="layui-textarea" style="min-height:60px"></textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <h4 style="margin-left: 100px">工作终结报告</h4>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" name="taskFinishReport" id="taskFinishReport" class="layui-textarea" style="min-height:60px"></textarea>
            </div>
        </div>
    </form>
</div>


<div id="Cha" style="display: none" class="layui-form-item">
    <form class="layui-form" id="ChaForm" lay-filter="ChaForm">
        <div class="layui-form-item">
            <input type="hidden" name="id">
            <table cellpadding="0" cellspacing="0" border="1" style="margin-top: 10px">
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">任务编码</td>
                    <td><input type="text" class="renWuBianMa" name="solveTaskCode" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">任务名称</td>
                    <td><input type="text" name="solveTaskName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">任务状态</td>
                    <td><input type="text" class="reWuZhuangTai" name="taskStatusName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">工作单据</td>
                    <td><input type="text"  class="GongZuoDanJu" name="workDocTypeName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">任务下发人</td>
                    <td><input type="text" class=".renWuXiaFaRen" name="issuedByName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">任务下发时间</td>
                    <td><input type="text" class="renWuXiaFaShiJian" name="issuedTime" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">任务负责人</td>
                    <td><input type="text" class="renWUFUZeRen"  name="taskManagerName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">任务描述</td>
                    <td><input type="text" class="renWuMiaoShu" name="taskDesc" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">消缺员</td>
                    <td><input type="text" class="xiaoQuYuan" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">任务完成时间</td>
                    <td><input type="text" class="RenWuWanChengShiJian" name="finishTime" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 40px;">
                    <td style="width: 180px;" align="center">负责人审查意见</td>
                    <td><input type="text" class="fuZeRenShenChaYiJian" name="managerSuggestion" disabled="disabled" style="border: none;height: 40px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">完成情况描述</td>
                    <td><textarea   placeholder="aa" disabled="disabled"  name="taskFinishDesc" id="taskFinishDesc2" class="layui-textarea" style="min-height:40px;border: none"></textarea></td>
                </tr>
                <tr style="height: 35px;">
                    <td style="width: 180px;" align="center"> 下发人审查意见</td>
                    <td><input type="text"  df name="issuedSuggestion" class="issuedSuggestion" disabled="disabled" style="border: none;height: 35px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">审核是否通过</td>
                    <td><input type="text" name="isCancel" class="isCancel"  disabled="disabled" style="border: none;height: 35px;padding-left: 20px"></td>
                </tr>
            </table>
        </div>
        <!--    <div style="margin-left: 100px;height: 200px;border: 1px slategrey solid">-->
        <!--        <h4>缺陷信息列表</h4>-->
        <!--        <table id="QueTb" lay-filter="QueTb" lay-data="QueTb"></table>-->
        <!--    </div>-->
        <div class="layui-form-item layui-form-text">
            <h4 style="margin-left: 100px">工作间断延期记载</h4>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" disabled="disabled" name="taskNotes" id="taskNotes2" class="layui-textarea" style="min-height:60px;border: none"></textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <h4 style="margin-left: 100px">工作终结报告</h4>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" disabled="disabled" name="taskFinishReport" id="taskFinishReport2" class="layui-textarea" style="min-height:60px;border: none"></textarea>
            </div>
        </div>
    </form>
</div>

<script type="text/html" id="active">
    <div class="layui-input-block" style="margin-left: 0px">
        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm"  lay-event="ChaKan" >查看</button>
        {{#  if(d.taskStatus == 36){  }}
        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm layui-btn-disabled" lay-event="zhixingluru">执行录入</button>
        {{# }else if(d.taskStatus==38){ }}
        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm layui-btn-disabled" lay-event="zhixingluru" >执行录入</button>
        {{# }else{ }}
        <!--"-->
        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="FenPeiRenWu">回执录入</button>
        {{# } }}

        {{#  if(d.taskStatus == 37){  }}
        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm layui-btn-disabled" lay-event="zh">执行</button>
        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm"  lay-event="update">修改</button>
        {{# }else if(d.taskStatus==38){ }}
        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm layui-btn-disabled" lay-event="zh" >执行</button>
        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm"  lay-event="update">修改</button>
        {{# }else{ }}
        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="zhixing">执行</button>
        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm  layui-btn-disabled"  lay-event="updatel">修改</button>
        {{# } }}
    </div>
    <!--回执-->
</script>
<script src="/webjars/layui/2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(["jquery","layer","form","table","laydate"],function () {
        let form = layui.form;
        let $ = layui.$;
        let table = layui.table;
        let laydate = layui.laydate;
        table.render({
            id: "AttTb",
            elem: "#AttTb",
            url: "/XiaoQueHuiZhi/XiaoQueCha",
            cols: [
                [
                    {field:'id',  title: 'ID',sort: true,hide: true}
                    ,{field: 'lineCode',title: '所属线路',hide: true}
                    ,{field:'solveTaskCode', title: '任务编号'}
                    ,{field:'solveTaskName', title: '任务名称'}
                    ,{field: 'workDocTypeName',title:'工作单据'}
                    ,{field: 'issuedByName',title:'下发人'}
                    ,{field: 'issuedTime',title:'下发时间'}
                    ,{field: 'taskStatusName',title:'任务状态'}
                    ,{field: 'finishTime',title:'任务完成时间'}
                    ,{field: 'aa',title:'操作',templet:"#active",width:"280"}
                ]
            ],
            page: {
                limit: 4,
                limits: [4, 8, 12]
            }

        })
        //表格监听
        table.on("tool(AttTb)",function ({data,event}) {
            switch (event) {
                case "FenPeiRenWu":
                    console.log(data.lineName)
                    console.log(data)
                    //回执录入
                    HuiZhi(data);
                    break;
                case "ChaKan":
                    console.log(data)
                    chaKan(data)
                    break;
                case "zhixing":
                    ZhiXing(data);
                    break;
                case "update":
                    XiuGai(data);
                    break;
            }
        })


        laydate.render({
            elem: '#kaishi'
        });
        laydate.render({
            elem: '#jeiShu'
        });

        /*工作单据下拉框赋值*/
        $.ajax({
            url:"/XiaoQueHuiZhi/ChaGongDan",
            dataType: 'json',
            success: function(data) {
                if (data!== null) {
                    $("#service").empty();
                    $("#service").append(new Option("--请选择--", " "));
                    $.each(data, function(index, item) {
                        $('#service').append(new Option(item.configName,item.id));
                    });
                } else {
                    $("#service").append(new Option("暂无数据", ""));
                }
                //重新渲染
                form.render("select");
            }
        })
    })

    function ChaXun() {
        layui.use(['form','layedit', 'laydate','table','jquery'], function(){
            var $ = layui.$;
            let solveTaskCode=$("#solveTaskCode").val();
            let workDocType=$("#service").val();
            let issuedByName=$("#issuedByName").val();
            let kai=$("#kaishi").val();
            let jie=$("#jeiShu").val();
            let where={solveTaskCode,workDocType,issuedByName,kai,jie,curr:1};
            layui.table.reload("AttTb",{where});
        });
    }
/*回执*/
    function HuiZhi(date) {
        let dd=null;
        layui.use(["layer","form","jquery","table"],function () {
            let layer=layui.layer;
            let $=layui.jquery;
            let form=layui.form;
            layui.form.val("addForm",date)
            $("#taskFinishDesc").val("")
            $("#taskNotes").val("")
            $("#taskFinishReport").val("")
            console.log(date.id)
            /*根据id查询子表数据*/
            $.ajax({
                url:"/XiaoQueHuiZhi/ChaQueZiShu?id="+date.id,
                dataType: 'json',
                success: function(k) {
                    //let a=new Array(k.inspectionTaskDelId)
                    console.log(k)
                }
            })
            layer.open({
                type:1,
                title:" 消缺任务执行与回执",
                area:["950px","600px"],
                btn:["保存","取消"],
                content:$("#add"),
                yes(){
                    let id=date.id;
                    /*修改任务状态*/
                    $.post("/XiaoQueHuiZhi/SiXiuZhuang",{"id":id})
                        .done(({msg})=>{
                            layer.close(layer.index);
                            layui.table.reload("AttTb");
                            layer.msg(msg);
                        })
                    /*修改完成时间*/
                    $.post("/XiaoQueHuiZhi/ShiJianSiXiuZhuang",{"id":id})
                        .done(({msg})=>{
                            layer.close(layer.index);
                            layui.table.reload("AttTb");
                            layer.msg(msg);

                        })
                    /*主表修改*/
                    let params=layui.form.val("addForm");
                    console.log(params)
                    $.post("/XiaoQueHuiZhi/XiuGaiZhu",params)
                        .done(({msg})=>{
                            layer.close(layer.index);
                            layui.table.reload("AttTb");
                            alert("保存成功")
                            layer.msg(msg);

                        })

                }
            })
            /*查询巡检主表的任务编号后利用编号拿到子表的taskid，用taskid查询数据*/
            // $.ajax({
            //     url:"/XiaoQueHuiZhi/ChaRenBian?solveTaskCode="+date.solveTaskCode,
            //     dataType: 'json',
            //     success: function(data) {
            //         console.log(data.id)
            //         $.ajax({
            //             url:"/XiaoQueHuiZhi/ChaRenBianZiShu?id="+data.id,
            //             dataType: 'json',
            //             success: function(k) {
            //                 console.log(k+"kkkkk")
            //
            //             }
            //         })
            //     }
            // })
        })
    }


    /*修改*/
    function XiuGai(date) {
        let dd=null;
        layui.use(["layer","form","jquery","table"],function () {
            let layer=layui.layer;
            let $=layui.jquery;
            let form=layui.form;
            layui.form.val("updateForm",date)
            console.log(date.id)
            /*根据id查询子表数据*/
            // $.ajax({
            //     url:"/XiaoQueHuiZhi/ChaQueZiShu?id="+date.id,
            //     dataType: 'json',
            //     success: function(k) {
            //         //let a=new Array(k.inspectionTaskDelId)
            //         console.log(k)
            //     }
            // })
            layer.open({
                type:1,
                title:" 消缺任务执行与回执",
                area:["950px","600px"],
                btn:["保存","取消"],
                content:$("#update"),
                yes(){
                    let id=date.id;
                    /*主表修改*/
                    let params=layui.form.val("updateForm");
                    console.log(params)
                    $.post("/XiaoQueHuiZhi/XiuGaiZhu",params)
                        .done(({msg})=>{
                            layer.close(layer.index);
                            layui.table.reload("AttTb");
                            alert("保存成功")
                            layer.msg(msg);

                        })

                }
            })
        })
    }

    /*查看*/
    function chaKan(date) {
        let dd=null;
        layui.use(["layer","form","jquery","table"],function () {
            let layer=layui.layer;
            let $=layui.jquery;
            let form=layui.form;
            layui.form.val("ChaForm",date)
            console.log(date.id)
            /*根据id查询子表数据*/
            // $.ajax({
            //     url:"/XiaoQueHuiZhi/ChaQueZiShu?id="+date.id,
            //     dataType: 'json',
            //     success: function(k) {
            //         //let a=new Array(k.inspectionTaskDelId)
            //         console.log(k)
            //     }
            // })
            layer.open({
                type:1,
                title:" 消缺任务执行与回执",
                area:["950px","600px"],
                content:$("#Cha")
            })
        })
    }

    function ZhiXing(data) {
        layui.use(["jquery","layer","form","table"],function () {
            let layer=layui.layer;
            let $=layui.$;
            console.log(data.id)
            layer.confirm("确定执行吗", {title: "执行确认"}, function (index) {
                $.post("/XiaoQueHuiZhi/ZhiSiXiuZhuang", {"id": data.id})
                    .done(({msg}) => {
                        layer.close(layer.index);
                        alert("执行成功")
                        layui.table.reload("AttTb");
                        layer.msg(msg);

                    })
            })
        })

    }
</script>
</body>
</html>